package com.ciko.code.http.Req;


import android.text.TextUtils;

import com.ciko.code.constant.Api;
import com.ciko.code.constant.Constants;
import com.ciko.code.http.BaseRequest;
import com.ciko.code.http.Res.UserTaibaoLoginRes;
import com.ciko.code.utils.Base64;
import com.ciko.code.utils.MD5Utils;

/**
 * Created by ciko on 2015/11/22.
 */
public class UserTaibaoLoginReq extends BaseRequest {

    public UserTaibaoLoginReq(String account, String password) {

        putClientType();
        putEnterpriseId();
        putTimeStamp();
        putAccountType();

        put("account", account);
        put("password", MD5Utils.StringMD5(password));
        put("cid", cid(account + Constants.ACCOUNT_TYPE + Constants.CLIENTTYPE + timeStamp + MD5Utils.StringMD5(password)));

    }

    @Override
    public String getUrl() {
        return Api.userLoginTaiBao;
    }

    protected String cid(String value) {
        if (!TextUtils.isEmpty(Constants.login_key))
            return Base64.base64Encode(value, Constants.login_key, "UTF-8");
        return Base64.base64Encode(value, Constants.SERVER_ENCRYPTKEY, "UTF-8");
    }

    @Override
    public Class<?> getResponseClazz() {
        return UserTaibaoLoginRes.class;
    }

}
